import {FooterToolbar, PageContainer, ProTable} from '@ant-design/pro-components';
import {ScrollRankingBoard} from '@jiaminghi/data-view-react'
import {useEffect, useState} from "react";
import {interfaceAnalysisUsingGET} from "@/services/api-backend/userInterfaceInfoController";


const Analysis: React.FC = () => {
  const [config, setConfig] = useState<any>({});

  const init = async () => {
    try {
      const res = await interfaceAnalysisUsingGET()
      if (res && res.data) {
        const arr: any = []
        res.data.forEach((e: { name: string; totalTimes: number; }) => {
          arr.push({name: e.name, value: e.totalTimes})
        })
        //http://datav-react.jiaminghi.com/guide/scrollRankingBoard.html#%E6%95%B0%E5%80%BC%E5%8D%95%E4%BD%8D
        setConfig({data: arr})
        console.log(arr)
      }
    } catch (e) {
    }
  }

  useEffect(() => {
    init()
  }, []);

  return (
    <PageContainer>
      <div style={{backgroundColor: '#282c34', padding: '20px'}}>
        <ScrollRankingBoard config={config} style={{width: '500px', height: '400px'}}/>
      </div>
    </PageContainer>
  );
};
export default Analysis;
